<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<html>
<head>
<title>
Zapatec Calendar Overview
</title>
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script>
function asd() {
	
		parent.document.title="zpbusycal.js Overview";
	
}
</script>
</head>
<body bgcolor="white" onload="asd();">

<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> 	<font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top">
<em>
<b>Zapatec Calendar</b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<center>
	
	   <h2>zpbusycal.js</h2>
	
</center>

	


<h4>Summary</h4>
<p>
	
		Zapatec Busy Calendar widget. Extends Zapatec Calendar widget
 and displays busy dates on it.

 <pre>
 Copyright (c) 2004-2009 by Zapatec, Inc.
 http://www.zapatec.com
 1700 MLK Way, Berkeley, California,
 94709, U.S.A.
 All rights reserved.
 </pre><BR/><BR/>
	
</p>

<hr>


    <table border="1" cellpadding="3" cellspacing="0" width="100%">
    <tr bgcolor="#CCCCFF" class="TableHeadingColor">
    <td colspan=2><font size="+2">
    
        <b>Class Summary</b>
    
    </font></td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="Zapatec/Busycal.html">Zapatec.Busycal</a></b></td>
    <td>&nbsp;</td>
    </tr>
    
    </table>
    <hr/> 


<!-- ========== METHOD SUMMARY =========== -->

<!-- ========== END METHOD SUMMARY =========== -->


        <pre class="sourceview"><span class="comment">/**
 * <span class="attrib">@fileoverview</span> Zapatec Busy Calendar widget. Extends Zapatec Calendar widget
 * and displays busy dates on it.
 *
 * &lt;pre&gt;
 * Copyright (c) 2004-2009 by Zapatec, Inc.
 * http://www.zapatec.com
 * 1700 MLK Way, Berkeley, California,
 * 94709, U.S.A.
 * All rights reserved.
 * &lt;/pre&gt;
 */</span>

<span class="comment">/* $Id: zpbusycal.js 17416 2009-05-06 08:08:48Z nmaxim $ */</span>

<span class="comment">/**
 * Zapatec Busy Calendar widget class. Extends Zapatec Calendar class.
 *
 * &lt;pre&gt;
 * Accepts JSON source only.
 *
 * Input data format:
 * {
 *   busydates: [
 *     array of busy dates as Date objects or strings in RFC 2445 (yyyymmdd) or
 *     ISO 8601 (yyyy-mm-dd) format
 *   ]
 * }
 *
 * If callbackSource config option is defined, callback function receives range
 * of displayed dates:
 * {
 *   from: [string] first displayed date in RFC 2445 format,
 *   to: [string] last displayed date in RFC 2445 format
 * }
 *
 * &lt;strong&gt;In addition to config options defined in base Zapatec.Calendar class
 * provides following config options:&lt;/strong&gt;
 *
 * &lt;b&gt;preloadMonths&lt;/b&gt; [number] Number of months to preload. 0 - no preload.
 * Default: 1.
 * &lt;/pre&gt;
 *
 * <span class="attrib">@constructor</span>
 * <span class="attrib">@extends</span> Zapatec.Calendar
 * <span class="attrib">@requires</span> Zapatec.Calendar Requires zpcal/src/calendar.js
 * <span class="attrib">@param</span> {any} any Any number of arguments passed to parent method
 */</span>
Zapatec.Busycal = <span class="reserved">function</span>() {
	<span class="comment">// Call constructor of superclass with passed arguments</span>
	zapatecBusycal.SUPERconstructor.apply(<span class="reserved">this</span>, arguments);
};

<span class="comment">/**
 * Shortcut for faster access.
 * <span class="attrib">@private</span>
 * <span class="attrib">@final</span>
 */</span>
zapatecBusycal = Zapatec.Busycal;

<span class="comment">/**
 * Unique static id of the widget class. Gives ability for
 * {<span class="attrib">@link</span> Zapatec#inherit} to determine and store path to this file correctly
 * when it is included using {<span class="attrib">@link</span> Zapatec#include}. When this file is included
 * using {<span class="attrib">@link</span> Zapatec#include} or path to this file is obtained using
 * {<span class="attrib">@link</span> Zapatec#getPath}, this value must be specified as script id.
 * <span class="attrib">@private</span>
 * <span class="attrib">@final</span>
 */</span>
Zapatec.Busycal.id = <span class="literal">'Zapatec.Busycal'</span>;

<span class="comment">// Inherit Zapatec Calendar</span>
Zapatec.inherit(zapatecBusycal, zapatecCalendar);

<span class="comment">/**
 * Configures the widget.
 *
 * <span class="attrib">@private</span>
 * <span class="attrib">@param</span> {any} any Any number of arguments passed to parent method
 */</span>
Zapatec.Busycal.<span class="reserved">prototype</span>.configure = <span class="reserved">function</span>() {
	<span class="comment">// Overwrite default config options</span>
	<span class="reserved">this</span>.defineConfigOption(<span class="literal">'dateStatusFunc'</span>, zapatecBusycal.dateStatusFunc);
	<span class="reserved">this</span>.defineConfigOption(<span class="literal">'preloadMonths'</span>, 1);
	<span class="reserved">this</span>.defineConfigOption(<span class="literal">'source'</span>, {});
	<span class="reserved">this</span>.defineConfigOption(<span class="literal">'sourceType'</span>, <span class="literal">'json'</span>);
	<span class="comment">// Call parent method with passed arguments</span>
	zapatecBusycal.SUPERclass.configure.apply(<span class="reserved">this</span>, arguments);
};

<span class="comment">/**
 * Default dateStatusFunc. See dateStatusFunc config option of
 * {<span class="attrib">@link</span> Zapatec#Calendar}.
 *
 * <span class="attrib">@private</span>
 * <span class="attrib">@param</span> {object} oDate Date object
 */</span>
Zapatec.Busycal.dateStatusFunc = <span class="reserved">function</span>(oDate) {
	<span class="comment">// Get data</span>
	var aBusydates = <span class="reserved">this</span>.data;
	<span class="reserved">if</span> (!aBusydates) {
		<span class="reserved">return</span>;
	}
	aBusydates = aBusydates.busydates;
	<span class="reserved">if</span> (!(aBusydates instanceof Array)) {
		<span class="reserved">return</span>;
	}
	<span class="comment">// Check date</span>
	<span class="reserved">if</span> (zapatecUtils.arrIndexOf(
		aBusydates,
		zapatecDate.dateToDateStamp({date: oDate})
	) &gt;= 0) {
		<span class="comment">// Display cell busy</span>
		<span class="reserved">return</span> <span class="literal">'zpBusycalBusy'</span>;
	}
	<span class="reserved">return</span> false;
};

<span class="comment">/**
 * Pulls information about busy dates from server. Preloads previous and next
 * months. Calls parent method first to display grid with previously preloaded
 * data. Then loads new data and updates grid with loaded data.
 *
 * <span class="attrib">@private</span>
 * <span class="attrib">@param</span> {any} any Any number of arguments passed to parent method
 */</span>
Zapatec.Busycal.<span class="reserved">prototype</span>._init = <span class="reserved">function</span>() {
	<span class="comment">// Call parent method with passed arguments</span>
	zapatecBusycal.SUPERclass._init.apply(<span class="reserved">this</span>, arguments);
	<span class="comment">// Check loaded flag</span>
	<span class="reserved">if</span> (<span class="reserved">this</span>.bcLoaded) {
		<span class="comment">// Remove flag</span>
		<span class="reserved">this</span>.bcLoaded = null;
	} <span class="reserved">else</span> {
		<span class="comment">// Get range of displayed dates in RFC 2445 format</span>
		var oRange = <span class="reserved">this</span>.getRange();
		var iPreloadDays = parseInt(<span class="reserved">this</span>.config.preloadMonths);
		<span class="reserved">if</span> (isNaN(iPreloadDays) || iPreloadDays &lt; 0) {
			iPreloadDays = 0;
		}
		iPreloadDays *= 42;
		var sFrom = zapatecDate.dateToDateStamp({
			<span class="comment">// Extend range to preload previous n days</span>
			date: zapatecDate.getTomorrow({
				date: oRange.from,
				days: -iPreloadDays
			})
		});
		var sTo = zapatecDate.dateToDateStamp({
			<span class="comment">// Extend range to preload next n days</span>
			date: zapatecDate.getTomorrow({
				date: oRange.to,
				<span class="comment">// End date is non-inclusive</span>
				days: iPreloadDays + 1
			})
		});
		<span class="reserved">if</span> (!sFrom || !sTo) {
			<span class="reserved">return</span>;
		}
		<span class="comment">// Abort previous data request</span>
		<span class="reserved">this</span>.loadDataAbort();
		<span class="comment">// Load data</span>
		<span class="comment">// Pass range to callbackSource</span>
		<span class="reserved">this</span>.loadData({
			from: sFrom,
			to: sTo
		});
	}
};

<span class="comment">/**
 * Loads data from JSON source.
 *
 * <span class="attrib">@private</span>
 * <span class="attrib">@param</span> {object} oData Input data object
 */</span>
Zapatec.Busycal.<span class="reserved">prototype</span>.loadDataJson = <span class="reserved">function</span>(oData) {
	<span class="comment">// Get data</span>
	<span class="reserved">if</span> (!(oData instanceof Object)) {
		oData = {};
	}
	<span class="reserved">if</span> (!(oData.busydates instanceof Array)) {
		oData.busydates = [];
	}
	<span class="comment">// Convert dates to RFC 2445 format</span>
	var fDateToDateStamp = zapatecDate.dateToDateStamp;
	var fTimeIsoToTimeStamp = zapatecDate.timeIsoToTimeStamp;
	var aBusydates = oData.busydates;
	var iDates = aBusydates.length;
	var oDate;
	<span class="reserved">for</span> (var iDate = 0; iDate &lt; iDates; iDate++) {
		oDate = aBusydates[iDate];
		<span class="reserved">if</span> (oDate instanceof Date) {
			aBusydates[iDate] = fDateToDateStamp({
				date: oDate
			});
		} <span class="reserved">else</span> {
			aBusydates[iDate] = fTimeIsoToTimeStamp({
				dateIso: oDate
			}).substr(0, 8);
		}
	}
	<span class="comment">// Store for later use</span>
	<span class="reserved">this</span>.data = oData;
	<span class="comment">// Flag data were loaded</span>
	<span class="reserved">this</span>.bcLoaded = true;
	<span class="comment">// Display grid</span>
	zapatecBusycal.SUPERclass.reinit.call(<span class="reserved">this</span>);
};
</pre>
	<hr>



<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
<b>Zapatec Calendar</b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<font size="-1">

</font>
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Thu May 21 12:19:39 2009</div>
</body>
</html>
